package com.lzm.ydpt.mvp.presenterimpl;

import com.byt.framlib.basemvp.BasePresenter;
import com.byt.framlib.basemvp.basebean.BaseResponseBean;
import com.byt.framlib.basemvp.boby.FormBodys;
import com.byt.framlib.basemvp.exception.ApiException;
import com.byt.framlib.basemvp.listener.OnLoadingErrorListener;
import com.byt.framlib.basemvp.listener.OnLoadingProgressListener;
import com.lzm.ydpt.entity.mall.ShopInfoBean;
import com.lzm.ydpt.module.mall.activity.ShopInfoDetailActivity;
import com.lzm.ydpt.mvp.api.ProgressSubscriber;
import com.lzm.ydpt.mvp.contract.ShopInfoDetailContract;
import com.lzm.ydpt.mvp.modelimpl.ShopInfoDetailModelImpl;

/**
 * 类名称：XhXnInfoDetailsPresenterImpl
 * 类描述：代理实现
 */
public class ShopInfoDetailPresenterImpl extends BasePresenter implements ShopInfoDetailContract.Presenter {

    private ShopInfoDetailContract.View mView;
    private ShopInfoDetailContract.Model mModel;

    public ShopInfoDetailPresenterImpl(ShopInfoDetailActivity context) {
        super(context);
        this.mView = context;
        this.mModel = new ShopInfoDetailModelImpl();
    }

    @Override
    public void onShopInfo(FormBodys formBodys) {
        mManager.http(mModel.onShopInfo(formBodys), getLifecycleProvider(), new ProgressSubscriber<>(mContext, new OnLoadingProgressListener<ShopInfoBean>() {
            @Override
            public void onLoadingResult(BaseResponseBean<ShopInfoBean> entity) {
                mView.onShopInfo(entity.getData());
            }
        }, new OnLoadingErrorListener() {
            @Override
            public void onError(ApiException e, String method) {
                mView.showErrorView(e.getDisplayMessage());
            }

            @Override
            public void onErrorResult(BaseResponseBean entity, String method) {
                mView.showErrorView(entity.getMessage());
            }
        }, "onShopInfo"));
    }
}